In order to set the gain in a control loop, it is already known practice to superimpose a sinusoidal signal on the reference variable and to compare the controlled variable and the control difference with one another in order to obtain, from this comparison, a criterion for setting the control gain, cf. DE-A 36 35 859. For this purpose, it is preferably the amplitudes of the controlled variable and of the control difference that are compared with one another. In addition, mention is made of measuring a phase margin and using this measurement to derive a criterion for setting the control gain. In comparing the amplitudes, synchronous rectifiers are used to filter out those oscillation components of the control difference and of the controlled variable whose frequency is equal to the input frequency. Using a control unit, the gain of the controller is then changed until a comparator establishes that the filtered-out oscillation components of the controlled variable and of the control difference are of equal magnitude. The known method is therefore an iterative method which takes up a lot of time or is slow on account of the step-by-step tuning. Evaluating the phase information requires a high degree of complexity and is likewise slow, as a result of step-by-step tuning. Reducing the number of comparison steps inevitably leads to greater inaccuracy. When comparing the amplitudes of the controlled variable and of the control difference, care should also be taken to ensure that the control gain is not set exactly, since oscillation components are not in phase with the input frequency of the controlled variable and the control difference. Furthermore, using a frequency which is different from the critical frequency presupposes that the loop gain at this frequency is known.